<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

<input type="text" id="i1" placeholder="请输入一个数字">
<input type="button" value="添加帅哥" onclick="f(1)">
<input type="button" value="添加美女" onclick="f(2)">


<script>
    function f(sum){
        let i = document.querySelector("#i1");
        switch (sum){
            case 1:
                for(let j = 0; j < i.value; j++){
                    let p = document.createElement("img");
                    p.src = "../a.jpg"
                    p.width = 200;
                    p.height = 200;
                    console.log("xxx");
                    document.body.append(p);
                }
                break;
            case 2:
                for(let j = 0; j < i.value; j++){
                    let c = document.createElement("img");
                    c.src = "../b.jpg";
                    c.width = 200;
                    c.height = 200;
                    console.log("hhh");
                    document.body.append(c);
                }
                break;


        }
    }

</script>
</body>
</html>